package com.appspot.zarm.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.zarm.controller.operations.Operation;
import com.appspot.zarm.controller.operations.OperationFactory;

public class Dispatcher extends HttpServlet {

	private static final long serialVersionUID = -3847377931609318253L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		String operationId = request.getParameter(RequestParameters.OPERATION_PARAM);
		Operation operation = null;
		
		if (operationId != null) {
			operation = OperationFactory.getOperation(operationId, getServletContext());
		} else {
			operation = OperationFactory.getOperation(OperationFactory.LAYOUT_OPERATION, getServletContext());
		}
		
		operation.execute(request, response);
	}







}
